# 作者：小七
# 2025年01月05日

def open_r():
    file = open('file2.txt', mode='r', encoding='utf-8')
    text = file.read()
    print(text)
    file.close()


def open_rw():
    file = open('file2.txt', mode='r+', encoding='utf-8')
    text = file.read()
    print(text)
    file.write('\n小七')
    file.close()


def open_w():
    file = open('file3.txt', mode='w', encoding='utf-8')
    # file.write('小七')
    file.close()


def open_a():
    file = open('file1', mode='a', encoding='utf-8')
    file.write(' how are you')
    file.close()


def use_readline():
    file = open("file2.txt", mode='r', encoding='utf-8')
    while True:
        text = file.readline()
        if not text:
            break
        print(text, end='')
    file.close()


if __name__ == '__main__':
    # open_r()
    # open_rw()
    # open_w()
    # open_a()
    use_readline()
